<%@codepage="65001"%>
<%session.codepage="65001"%>
<!-- #include virtual=/inc/dbConn.asp -->
<!-- #include virtual=/inc/function.asp -->
<!-- #include virtual=/inc/action.header.inc.asp -->

<%
	'## 파라미터 변수 선언부
	issuedMemo	= Request("findIssuedMemo")
	srcCd		= Request("findSrcCd")
	flag			= Request("findFlag")
	types		= Request("findtype")
	stDate		= Request("stDate")
	endDate	= Request("endDate")

	SQLTitle = "-- ■■■■ 원자재 관리 정보 그리드 List up ■■■■"
	
	'## 검색조건에 따른 조건절 만들기 
	If srcCd <> "" Then 
		addSql = " A.srcCd='" & srcCd & "' "
	End If 
	If issuedMemo <> "" Then 
		If addSql <> "" Then addSql = addSql & " AND "
		addSql = addSql & " issuedMemo LIKE '%" & issuedMemo & "%' "
	End If 
	If flag = "" Then 
		If addSql <> "" Then addSql = addSql & " AND "
		addSql = addSql & " A.flag='Y' "
	End If 
	If stDate <> "" Then 
		If addSql <> "" Then addSql = addSql & " AND "
		addSql = addSql & " A.issuedDt>='" & stDate & "' "
	End If 
	If endDate <> "" Then 
		If addSql <> "" Then addSql = addSql & " AND "
		addSql = addSql & " A.issuedDt<='" & endDate & "' "
	End If 
	If types <> "" Then 
		If addSql <> "" Then addSql = addSql & " AND "
		addSql = addSql & " B.type = '" & types & "' "
	End If 

	If addSql <> "" Then 
		addSql = " WHERE " & addSql 
	End If 

	SQL = "SELECT A.seq, A.srcCd, B.srcNm, A.input, A.output, A.issuedMemo, A.issuedDt, A.flag, B.type FROM tblSrcInOut A " & _
			" LEFT JOIN tblSrc B ON A.srcCd=B.srcCd " & addSql & " ORDER BY A.addDt DESC" 

	If xMode="debug" Then 
		Call showDebug(SQLTitle,SQL) 
	End If 

	Set Rs=Server.CreateObject("ADODB.RecordSet")
	Rs.open SQL, DbCon, 1
	
	Response.write "<Sources>" & vbcrlf

	If Rs.eof Or Rs.bof Then 
	Else 
		Do Until Rs.eof Or Rs.bof
		
			Response.write "	<SrcList>" & vbcrlf
				Call mkXMLNode("seq", rs("seq"), 2)
				Call mkXMLNode("srcCd", rs("srcCd"), 2)
				Call mkXMLNode("srcNm", rs("srcNm"), 2)
				Call mkXMLNode("input", rs("input"), 2)
				Call mkXMLNode("output", rs("output"), 2)
				Call mkXMLNode("type", rs("type"), 2)
				Call mkXMLNode("issuedMemo", rs("issuedMemo"), 2)
				Call mkXMLNode("issuedDt", rs("issuedDt"), 2)
				Call mkXMLNode("flag", Rs("flag"), 2)
			Response.write "	</SrcList>" & vbcrlf

		Rs.movenext
		Loop 
	End If
	Response.write "</Sources>" & vbcrlf
'	Call rsWithXML("Save OK!")
%>